package com.qf.serviceimpl;

import com.qf.mapper.StatMapper;
import com.qf.service.StatService;
import com.qf.vo.CategorySellAmts;
import com.qf.vo.DayStatis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.serviceimpl
 * @Description:
 * @Date 2022/10/13 21:28
 */
@SuppressWarnings("all")
@Service
public class StatServiceImpl implements StatService {

    @Autowired
    StatMapper statMapper;

    @Override
    public List<CategorySellAmts> findCategorySell() {
        return statMapper.findCategorySell();
    }

    @Override
    public List<DayStatis> findOrder() {
        Calendar calendar = Calendar.getInstance();
        calendar.add(Calendar.MONTH, -1);

        Date time = calendar.getTime();

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd 00:00:00");

        String format = simpleDateFormat.format(time);

        return statMapper.findOrder(format);
    }

    @Override
    public List<DayStatis> findUser() {
        return statMapper.findUser();
    }
}
